﻿$(document).ready(function () {
    $("#ul-nav li:not(.nav-header)").eq(3).addClass("active");
    page.init();
});

var page = {
    pageIndex: 0,
    pageSize: 10,
    url: "/handler/admin/integration.ashx?action=",
    popU: null,

    init: function () {
        page.getList();
    },

    getList: function (pageIndex) {
        var month = $.trim($("#month").val());
        var now = new Date();
        if (month == "") {
            month = now.getFullYear() + "-" + (now.getMonth() + 1) + "-1";
            $("#month").prev().val(now.getFullYear() + "年" + (now.getMonth() < 9 ? "0" : "") + (now.getMonth() + 1) + "月");
        }

        if (pageIndex != undefined)
            page.pageIndex = pageIndex;

        $.get(page.url + "transaction", { month: month, r: Math.random(), pageIndex: page.pageIndex, pageSize: page.pageSize
        }, function (data) {
            $("#result").html(TrimPath.processDOMTemplate("transaction", data));
            page.pager(data.count);
        }, "json");
    },

    pager: function (count) {
        if (count == 0) {
            $("#pagination").empty();
            return;
        }
        $("#pagination").pagination(count, {
            num_edge_entries: 2,
            num_display_entries: 10,
            current_page: page.pageIndex,
            items_per_page: page.pageSize,
            callback: page.getList
        });
    }
};

